#include <stdio.h>
#include <time.h>
int main(int argc,const char*argv[])
{

	time_t ttime=0;
	struct tm*day_time=NULL;
	FILE*p=NULL;
	if((p=fopen(argv[1],"a"))==NULL){perror("文件打开失败：");return -1;}
	while(1)
	{
		if(ttime!=time(NULL))
		{
			ttime=time(NULL);
			day_time=localtime(&ttime);
			//printf("\033c");
			printf("%4d-%02d-%02d  %02d:%02d:%02d\n",day_time->tm_year+1900
					 ,day_time->tm_mon+1
					 ,day_time->tm_mday
					 ,day_time->tm_hour
					 ,day_time->tm_min
					 ,day_time->tm_sec);
			//写入文件格式可读
			fprintf(p,"%4d-%02d-%02d  %02d:%02d:%02d\n",day_time->tm_year+1900
					 ,day_time->tm_mon+1
					 ,day_time->tm_mday
					 ,day_time->tm_hour
					 ,day_time->tm_min
					 ,day_time->tm_sec);
			//写入为编码格式，不可阅读
			//fwrite(&day_time,sizeof(struct tm),1,p);
			fflush(p);
		}
	}
	fclose(p);
	return 0;
}
2024-10-17  17:04:58
2024-10-17  17:04:59
2024-10-17  17:05:00
2024-10-17  17:05:01
2024-10-17  17:05:02
2024-10-17  17:05:03
2024-10-17  17:05:04
2024-10-17  17:05:05
2024-10-17  17:05:06
2024-10-17  17:05:07
2024-10-17  17:05:08
2024-10-17  17:05:09
2024-10-17  17:05:10
2024-10-17  17:05:11
2024-10-17  17:05:12
2024-10-17  17:05:13
2024-10-17  17:05:14
2024-10-17  17:05:15
2024-10-17  17:05:16
2024-10-17  17:05:17
2024-10-17  17:05:18
2024-10-17  17:05:19
2024-10-17  17:05:20
2024-10-17  17:05:21
2024-10-17  17:05:22
2024-10-17  17:05:23
2024-10-17  17:05:24
2024-10-17  17:05:25
2024-10-17  17:05:26
2024-10-17  17:05:27
2024-10-17  17:05:28
2024-10-17  17:05:29
2024-10-17  17:05:30
2024-10-17  17:05:31
2024-10-17  17:05:32
2024-10-17  17:05:33
2024-10-17  17:05:34
2024-10-17  17:05:35
2024-10-17  17:06:59
2024-10-17  17:07:00
2024-10-17  17:07:01
2024-10-17  17:07:02
2024-10-17  17:07:03
2024-10-17  17:07:04
2024-10-17  17:07:05
2024-10-17  17:07:06
2024-10-17  17:07:07
2024-10-17  17:07:08
2024-10-17  17:07:09
2024-10-17  17:07:10
2024-10-17  17:07:11
2024-10-17  17:07:12
2024-10-17  17:07:13
2024-10-17  17:07:14
2024-10-17  17:07:15
2024-10-17  17:07:16
2024-10-17  17:07:17
2024-10-17  17:07:18
2024-10-17  17:07:19
2024-10-17  17:07:20
2024-10-17  17:07:21
2024-10-17  17:07:22
2024-10-17  17:07:23
2024-10-17  17:07:24
2024-10-17  17:07:25
2024-10-17  17:07:26
2024-10-17  17:07:27
2024-10-17  17:07:28
2024-10-17  17:07:29
2024-10-17  17:07:30
2024-10-17  17:07:31
2024-10-17  17:07:32
2024-10-17  17:07:33
2024-10-17  17:07:34
2024-10-17  17:07:35
2024-10-17  17:07:36
2024-10-17  17:07:37
2024-10-17  17:07:38
2024-10-17  17:07:39
2024-10-17  17:07:40
2024-10-17  17:07:41
2024-10-17  17:07:42
2024-10-17  17:07:43
2024-10-17  17:07:44
2024-10-17  17:07:45
2024-10-17  17:07:46
2024-10-17  17:07:47
2024-10-17  17:07:48
2024-10-17  17:07:49
2024-10-17  17:07:50
2024-10-17  17:07:51
2024-10-17  17:07:52
2024-10-17  17:07:53
2024-10-17  17:07:54
2024-10-17  17:07:55
2024-10-17  17:07:56
2024-10-17  17:07:57
2024-10-17  17:07:58
2024-10-17  17:07:59
2024-10-17  17:08:00
2024-10-17  17:08:01
2024-10-17  17:08:02
2024-10-17  17:08:03
2024-10-17  17:08:04
2024-10-17  17:08:05
2024-10-17  17:08:06
2024-10-17  17:08:07
2024-10-17  17:08:08
2024-10-17  17:08:09
2024-10-17  17:08:10
2024-10-17  17:08:11
2024-10-17  17:08:12
2024-10-17  17:08:13
2024-10-17  17:08:14
2024-10-17  17:08:15
2024-10-17  17:08:16
2024-10-17  17:08:17
2024-10-17  17:08:18
2024-10-17  17:08:19
2024-10-17  17:08:20
2024-10-17  17:08:21
2024-10-17  17:08:22
2024-10-17  17:08:23
2024-10-17  17:08:24
2024-10-17  17:08:25
